﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Sustainalytics.SharedEntities.EsgResearch;
using Sustainalytics.ClientDW.Synchronization.SyncESGData.AbstractClassesAndInterfaces;

namespace Sustainalytics.ClientDW.Synchronization.SyncESGData.SourceLogic
{
    public class SourceOrchestrator : IComprehensiveEsgSyncOrchestrator<Source>
    {
        private readonly IComprehensiveEsgSourceQuery sourceQuery;
        private readonly SourceCommand sourceCommand;

        public SourceOrchestrator(SourceQuery sourceQuery, SourceCommand sourceCommand)
        {
            this.sourceQuery = sourceQuery;
            this.sourceCommand = sourceCommand;
        }
        
        async Task IComprehensiveEsgSyncOrchestrator<Source>.OrchestrateAsync(IList<Source> comprehensiveEsgEntities, IList<Guid> invalidatedCompaniesIds)
        {
            await sourceCommand.ExecuteAsync(comprehensiveEsgEntities ?? sourceQuery.Get());
        }
    }
}
